package com.tem.system.service.impl;

import com.api.manage.pojo.system.SystemLevelTypeBean;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tem.system.entity.SysTypePermission;
import com.api.manage.pojo.system.SysTypePermissionBean;
import com.tem.system.entity.SystemLevelType;
import com.tem.system.mapper.SysTypePermissionMapper;
import com.tem.system.service.ISysTypePermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 系统等级资源--系统权限 服务实现类
 * </p>
 *
 * @author 腾木
 * @since 2023-11-29
 */
@Service
public class SysTypePermissionServiceImpl extends ServiceImpl<SysTypePermissionMapper, SysTypePermission> implements ISysTypePermissionService {
    public List<SysTypePermissionBean> getListBean(Long systemLevelTypeId){
        if(systemLevelTypeId==null)return null;
        QueryWrapper<SysTypePermission> wrapper = new QueryWrapper();
        wrapper.lambda().eq(SysTypePermission::getSystemLevelTypeId,systemLevelTypeId);
        List<SysTypePermission> list = this.list(wrapper);
        List<SysTypePermissionBean> beans = new ArrayList<>();
        SysTypePermissionBean bean=null;
        for(SysTypePermission t:list){
            bean = new SysTypePermissionBean();
            BeanUtils.copyProperties(t,bean);
            beans.add(bean);
        }
        return beans;
    }
}
